using System;
using System.Xml;
using System.Xml.Serialization;

namespace FrontDisplay.Weather
{
    [Serializable]
    public class City
    {
        public City() { }

        public City(XmlNode node)
        {
            Code = node.GetAttribute("id", string.Empty);
            Name = node.InnerText;
        }

        public City(string name, string code)
        {
            Name = name;
            Code = code;
        }

        [XmlAttribute]
        public string Name { get; set; }

        [XmlAttribute]
        public string Code { get; set; }

        public Uri GetXmlUrl(bool isCelsius)
        {
            return new Uri(string.Format("http://xml.weather.yahoo.com/forecastrss/{0}_{1}.xml", Code, isCelsius ? "c" : "f"));
        }

        public override string ToString()
        {
            return Name;
        }
    }
}